﻿<!DOCTYPE html>
<html>
<head>
    <title>@ViewData["Title"]</title>
    <script src="_content/AntQuartzUI/dayJs/advancedFormat.js"></script>
    <script src="_content/AntQuartzUI/dayJs/customParseFormat.js"></script>
    <script src="_content/AntQuartzUI/dayJs/dayjs.min.js"></script>
    <script src="_content/AntQuartzUI/dayJs/localeData.js"></script>
    <script src="_content/AntQuartzUI/dayJs/quarterOfYear.js"></script>
    <script src="_content/AntQuartzUI/dayJs/weekday.js"></script>
    <script src="_content/AntQuartzUI/dayJs/weekOfYear.js"></script>
    <script src="_content/AntQuartzUI/dayJs/weekYear.js"></script>
    <link rel="stylesheet" href="_content/AntQuartzUI/ant/reset.css">
    <script src="_content/AntQuartzUI/vue/vue.global.js"></script>
    <script src="_content/AntQuartzUI/ant/antd.js"></script>
    <script src="_content/AntQuartzUI/ant/antd.min.js"></script>
    <script src="_content/AntQuartzUI/axios/axios.min.js"></script>
    @RenderSection("Styles", required: false)
</head>
<body>
    @inject Microsoft.AspNetCore.Antiforgery.IAntiforgery Xsrf
    @functions{

        private string GetAntiXsrfRequestToken()
        {
            return Xsrf.GetAndStoreTokens(Model.HttpContext).RequestToken;
        }

        private string GetGetAntiXsrfRequestTokenName()
        {
            return Xsrf.GetAndStoreTokens(Model.HttpContext).HeaderName;
        }
    }


<div style="height: 100%;width: 100%;padding: 0;margin: 0;">
    @RenderBody()
</div>

<script>
    const {message} = antd
    
    // axios拦截
    axios.interceptors.request.use(
        function (config) {
            config.headers.@GetGetAntiXsrfRequestTokenName() = "@GetAntiXsrfRequestToken()";
            return config;
        },
        function (error) {
            return error;
        }
    );
    axios.interceptors.respnse.use(
        function (response) {
            if(response.data.code !== 200){
                message.error(response.data.message);
                return Promise.reject(new Error(response.data.message));
            }
            
            return response;
        },
        function (error) {
            message.error(error.response.data.message);
            return error;
        }
    )
    
</script>
@await RenderSectionAsync("scripts", required: false)
</body>
</html>